<?=header("content-type: application/x-javascript")?>

<script type="text/javascript" language="javascript">
$(document).ready(function() {
	// blink script
	
	function startpage() {
	$('#notice').blink();
	$("#action_button").click(function() {
		var email = $("#email").val();
		var password = $("#password").val();
		var dataString = '&email=' + email + '&password=' + password;
		if(email=='' ||  password=='') {
			$('#success').fadeOut(400).hide();
			$('#error').fadeOut(400).show();
		} else {
			$.ajax({
			type: "POST",
			dataType: "JSON",
			url: "<?=base_url()?>index.php/home/logsig",
			data: dataString,
			json: {session_state: true},
			success: function(data){
			if(data.session_state == true) { // true means user is logged in.
				$("#main1").hide();
				$("#main1").load('<?=base_url()?>index.php/home/dashboard').fadeIn(400);
			} else if(data.session_state == false) { // false means user is being registered.
				$("#action_button").hide();
				$('#success').load('<?=base_url()?>index.php/home/register');
				// onLoad fadeIn
		   	}
		  }
	   });
	  }
	});
	
	function dashboard() {
		$(".link1").click(function(clicked) {
			$.ajax(type: "POST", dataType: "JSON", url: "<?=base_url()?>index.php/home/kill_sess",
				   data: clicked, json: {clicked_logout: true}, success: function(data) {
					   if(data.clicked_logout == true) { // true means the Logout button was clicked
					   		$("#main1").hide();
							$("#main1").load('<?=base_url()?>index.php/home/register').fadeIn(400);
					   }
				   });
		});
	}
});
</script>